'use strict';
//webapck 基础配置
const path = require("path");
const webpack = require("webpack");
const HtmlWebpackPlugin = require("html-webpack-plugin");

module.exports = {
    //context: path.resolve(__dirname, ''),
    //配置简写路径
    resolve: {
        extensions: ['.js','.json'],
        alias: {
            '@': path.resolve(__dirname, 'src')
        }
    },
    module: {
        rules: [
            {
                test: /\.less$/,
                use: [
                    "style-loader",
                    "css-loader",
                    "postcss-loader?sourceMap",
                    "resolve-url-loader",
                    //"less-loader?sourceMap"
                    { loader: 'less-loader?sourceMap', options: { javascriptEnabled: true } }
                ]
            },
            {
                test: /\.js$/,
                include: path.join(__dirname, "src"),
                loader: "babel-loader",
                exclude:'/node_modules',
            },
            {
                test: /\.(jpe?g|png|gif|svg)$/i,
                use: [
                    'url-loader?limit=10000&name=img/[name]-[hash:5].[ext]',
                    'image-webpack-loader'
                ]
            }
        ]
    },
    //警告信息
    performance: {
        //hints: true
    },
    plugins: [
        //更改了chunk命名方式，缓存vendor的打包文件 【各个模块的ID已经变成一小段哈希值】
        new webpack.NamedModulesPlugin(),
        new HtmlWebpackPlugin({
            template:'./public/index.html',
            filename:'index.html',
            title:'这是一个title',
            files:{
                'name':'vane'
            }
            //排除
            //excludeChunks:[]
        })
    ]
};
//  "plugins": ["react-hot-loader/babel"]